<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>

      /*清理样式*/
      html{
        padding: 0;
        margin: 0;
      }
      p{
        margin: 0px;
      }
      a{
        text-decoration: none;
      }

      /*设置背景*/
      body{
        padding: 0;
        margin: 0;
        background-color: #f8f9fa;
      }

      .navbar{
          text-align: center;
          width: 30%;
          height: 1000px;
      }
      .p1{

        width: 300px;
        font-size: 40px;
        font-weight: bold;
        color: #50596c;
        display: inline-block;
        border-bottom: 1px dashed #e7e9ed;
        padding-bottom: 20px;
        padding-top: 50px;
      }
      .p2{
       
        font-size: 30px;
        color: #989FAF;
        padding-left: 50px;
        position: relative;
        top:-4px;
        line-height: 70px;
      }
      .glyphicon{
        line-height: 62px;
        color: #989FAF;
        font-size: 30px;
        padding-left: 50px;
      }
      .fl{
        float: left;
      }
      .HomeDiv{ 
        height: 60px;
        border-bottom: 1px dashed #000;
      }
      .position{
        position: fixed;
        left:3%;
        top:0px;
      }

      /*设置当鼠标移到的时候，变成灰色*/
      .active{
        background-color: gray;
      }

    </style>
  </head>
  <body>

    <nav class="navbar navbar-default">
      <div class="container">

        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">

          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

          <div class="nav navbar-nav navbar-left position">

              <p class="p1">ZMX's Blog</p><br>

               <a href="">
                <div class="HomeDiv">
                  <i class="glyphicon glyphicon-home fl"></i>
                  <p class="p2 fl">首页</p>
                </div>
              </a>

               <a href="">
                <div class="HomeDiv" style="clear: both;">
                  <i class="glyphicon glyphicon-home fl"></i>
                  <p class="p2 fl">简介</p>
                </div>
              </a>

              <a href="">
                <div class="HomeDiv" style="clear: both;">
                  <i class="glyphicon glyphicon-home fl"></i>
                  <p class="p2 fl">随笔</p>
                </div>
              </a>

               <a href="">
                <div class="HomeDiv" style="clear: both;">
                  <i class="glyphicon glyphicon-home fl"></i>
                  <p class="p2 fl">文章</p>
                </div>
              </a>
          </div>

        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="../jquery-3.3.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <script>
          <!-- 获取所有的a -->
          var as = $("a");

          // 获取左边的div
          var divs = $(".position div");

          // 对每个a绑定鼠标移上事件
          for(var i =0;i<as.length;i++){

            as[i].index = i;

            $(as[i]).mouseover(function(){

              //排他
              for(var j = 0;j<as.length;j++){

                $(divs[j]).removeClass("active");
              }

              $(divs[this.index]).addClass("active");
            })

            $(as[i]).mouseout(function(){

              //排他
              for(var j = 0;j<as.length;j++){

                $(divs[j]).removeClass("active");
              }
            })
          }
    </script>
  </body>
</html>